<?php

/**
 * This file is part of the Pagizer package.
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 *
 * @copyright   Copyright (c) 2010 Advisa (http://www.advisa.fr)
 * @author      Pagizer Core Team <team@pagizer.org>
 * @package     Pagizer
 * @subpackage  backoffice
 */

class m_backoffice_actions_block_AjaxPaginationAction extends f_core_Action
{
	public function execute()
	{
		$nbDocTot = intval($this->getBlockParameter("nbDocTot"));
		$nbDoc = intval($this->getBlockParameter("nbDoc"));
		$numPage = intval($this->getBlockParameter("numPage"));

		$nbPageTot = ceil($nbDocTot/$nbDoc);

		if($nbPageTot > 0)
		{
            $this->addToModel("nbDocTot", $nbDocTot);
			$this->addToModel("nbPageTot", $nbPageTot);
			$this->addToModel("nbDoc", $nbDoc);
			$this->addToModel("numPage", $numPage);
			$this->setView('success');
		}
		else
		{
			return "";
		}
	}
	
	public function validate()
	{
		return true;
	}
}